home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / example.rep / code.ys < prev   
Encoding:
Text File  |  2002-03-13  |  1.5 KB  |  97 lines

  1.  
  2.  
  3. examplelist:=
  4. Hold(
  5. {
  6.   {40!,
  7. "Simple factorial of a number.
  8. "
  9.   },
  10.   {D(x)Sin(x),
  11. "Taking the derivative of a function (the derivative of Sin(x) with
  12. respect to x in this case).
  13. "
  14.   },
  15.   {Taylor(x,0,5)Sin(x),
  16. "Expanding a function into a taylor series.
  17. "
  18.   },
  19.   {Integrate(x,a,b)Sin(x),
  20. "Integrate a function.
  21. "
  22.   },
  23.   {Solve(a+x*y==z,x),
  24. "Solve a function for a variable.
  25. "
  26.   },
  27.   {Limit(x,0) Sin(x)/x,
  28. "Take a limit.
  29. "
  30.   },
  31.   {Subst(x,Cos(a)) x+x,
  32. "Substitute an expression with another in the main expression.
  33. "
  34.   },
  35.   {Expand((1+x)^3),
  36. "Expand into a polynomial.
  37. "
  38.   },
  39.   {2^40,
  40. "Big numbers.
  41. "
  42.   },
  43.   {1<<40,
  44. "Bitwise operations
  45. "
  46.   },
  47.   {1 .. 4,
  48. "Generating a list of numbers.
  49. "
  50.   },
  51.   {a:b:c:{},
  52. "Generating a list of items.
  53. "
  54.   },
  55.   {[Local(x);x:={a,b,c};Sin(x)^2;],
  56. "Threading: Sin(..)^2 will be performed on all elements of the list
  57. passed in.
  58. "
  59.   },
  60.   {[Local(list);list:={a,b,c,d,e,f}; list[2 .. 4];],
  61. "Selecting a sublist from a list.
  62. "
  63.   },
  64.   {Permutations({a,b,c}),
  65. "Generate all permutations of a list.
  66. "
  67.   },
  68.   {VarList(a+b*x),
  69. "Show all variables that occur in an expression.
  70. "
  71.   },
  72.   {TrigSimpCombine(Cos(a)*Cos(a)+Sin(a)*Sin(a)),
  73. "Convert factors between trigonometric functions to addition of
  74. trigonometric functions.
  75. "
  76.   }
  77. }
  78. );
  79. exampleindex:=0;
  80.  
  81. Example():=
  82. [
  83.   exampleindex++;
  84.   If (exampleindex>Length(examplelist),exampleindex:=1);
  85.  
  86.   Local(example);
  87.   example:=examplelist[exampleindex];
  88.   WriteString("Current example : ");
  89.   Write(example[1]);WriteString(";");NewLine();
  90.   NewLine();
  91.   WriteString(example[2]);
  92.   NewLine();
  93.   Eval(example[1]);
  94. ];
  95.  
  96.  
  97.